home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
- <stack>
- <name>in</name>
- <id>-1</id>
- <cardCount>4</cardCount>
- <cardID>2850</cardID>
- <listID>5625</listID>
- <cantModify><false /></cantModify>
- <cantDelete><false /></cantDelete>
- <cantAbort><false /></cantAbort>
- <cardSize>
- <width>288</width>
- <height>220</height>
- </cardSize>
- <script>========================================================================
- IN-OUT BOARD
- by Danny Goodman
-
- Supplement to May 1992 MacUser article on HyperCard and Apple Events
- ©1991 Danny Goodman
- ========================================================================
-
- -- Make sure 'server' address is available in this stack
- on openStack
- if fld "Program Address" is empty then fillAddress
- end openStack
-
- -- Access program linking dialog to find 'server' address
- -- Then store it in local stack field for use by other handlers.
- on fillAddress
- answer program "Choose the Macintosh and HyperCard running the “Out of Office Server.”"
- if it is empty then exit fillAddress
- put it into fld "Program Address"
- end fillAddress
-
- -- Find out if HyperCard is running on the 'server'
- -- and whether server stack is active
- function InOutIsActive theProgram
- request "short name of this stack" from program theProgram
- if the result is "No such program" then
- answer "The In-Out Server is not responding."
- return false
- else
- if it is "In-Out Board"
- then return true
- else return false
- end if
- end InOutIsActive
-
- -- Assembles and sends message to server to bring the server
- -- stack to the forefront. Messages and screen are locked to
- -- prevent user at the server machine from being distracted
- -- by all the window flipping. Set this as a function to return
- -- TRUE when we actually had to go to this stack on the 'server.'
- -- That way, we'll know to do a POP after we're finished reading
- -- or writing...to put target Mac back in original state.
- function goToServer theProgram
- put "lock screen" into serverMsg
- put "lock messages" into line 2 of serverMsg
- put "push card" into line 3 of serverMsg
- put "go to stack" && quote & "In-Out Board" & quote into line 4 of serverMsg
- send serverMsg to program theProgram
- if the result is not empty
- then return false
- else return true
- end goToServer
-
- -- These two functions remove and restore carriage return
- -- characters in the note text, so that multiple-line notes
- -- can be safely stored in a single HyperCard line.
- function scrunch theText
- put numToChar(16) into delimChar
- repeat until offset(return,theText) = 0
- put delimChar into char offset(return,theText) of theText
- end repeat
- return theText
- end scrunch
-
- function unScrunch theText
- put numToChar(16) into delimChar
- repeat until offset(delimChar,theText) = 0
- put return into char offset(delimChar,theText) of theText
- end repeat
- return theText
- end unScrunch
-
- -- Double checks that there is a target program name stored locally.
- -- Then directs message to same stack (user and 'server' are
- -- on same Mac) or to target program on another Mac.
- on startSend
- put fld "Program Address" into theProgram
- if theProgram is not empty then
- if the address is theProgram -- user is also acting as server
- then setStatus myStatus()
- else sendDataToServer theProgram -- gotta send apple event
- end if
- end startSend
-
- -- Writes information to the 'server' when it is on a different
- -- Macintosh. Calls other functions to check whether target
- -- program is running and whether the 'server' stack is running
- on sendDataToServer theProgram
- global undoRadioBtn,undoNote
- if not InOutIsActive(theProgram) then
- if goToServer(theProgram)
- then put true into needToPop -- we pushed to get here
- else
- answer "Problem accessing the In-Out Server."
- repeat with x = 1 to 7
- set hilite of bg btn x to false
- end repeat
- if there is a bg btn undoRadioBtn
- then set hilite of bg btn undoRadioBtn to true
- put undoNote into fld "Note"
- exit sendDataToServer
- end if
- end if
- send "setStatus" && quote & myStatus() & quote & "" to program theProgram
- if needToPop is true -- must restore target HC to former stack
- then send "pop card" to program theProgram
- end sendDataToServer
-
- -- Assembles data from radio buttons and note field into the
- -- data line that ultimately gets stored on the 'server.'
- function myStatus
- global userName
- if userName is empty then
- answer "Go to last card of Home stack and enter your userName"
- exit myStatus
- end if
- put numToChar(15) into itemDelim
- repeat with x = 1 to 7
- if hilite of bg btn x then
- put short name of bg btn x into theStatus
- exit repeat
- end if
- end repeat
- return userName & itemDelim & theStatus & itemDelim & scrunch(fld "Note")
- end myStatus
-
- -- Executes only when the user is also the 'server.'
- -- Writes new data to the hidden "Group Status" field.
- -- Handler uses the user name to find the line number containing
- -- any previous entry for the user. If there is none, then it
- -- appends the data to the end of the field.
- on setStatus theData
- set itemDelimiter to numToChar(15)
- put item 1 of theData & numToChar(15) into theName
- set itemDelimiter to comma
- put lineNumber(theName,fld "Group Status" of cd 1) into whichLine
- if whichLine ‚â§ 0
- then put (number of lines of fld "Group Status" of cd 1) + 1 into whichLine
- put theData into line whichLine of fld "Group Status" of cd 1
- end setStatus
-
- ==========
- -- Handlers called by other users when the stack is the 'server.'
-
- -- Writes new data to the hidden "Group Status" field.
- -- Handler uses the user name to find the line number containing
- -- any previous entry for the user. If there is none, then it
- -- appends the data to the end of the field.
- -- Also executes when the user is also the 'server.'
- on setStatus theData
- set itemDelimiter to numToChar(15)
- put item 1 of theData & numToChar(15) into theName
- set itemDelimiter to comma
- put lineNumber(theName,fld "Group Status" of cd 1) into whichLine
- if whichLine ‚â§ 0
- then put (number of lines of fld "Group Status" of cd 1) + 1 into whichLine
- put theData into line whichLine of fld "Group Status" of cd 1
- end setStatus
-
- -- A fast way to find which line of a container holds some text.
- function lineNumber matchText,fullText
- return (number of lines of char 1 to offset(matchText,fullText) of fullText)
- end lineNumber
-
- -- Retrieves a list of names only from the data field. References
- -- are to cd 1 in case the person on the 'server' machine is
- -- in the In-Out stack, but on a different card.
- function userList
- put empty into theUsers
- set itemDelimiter to numToChar(15)
- push card
- if there is no fld "Group Status" of cd 1 then
- lock screen
- lock messages
- go to stack "In-Out Board"
- end if
- get fld "Group Status" of cd 1
- repeat with x = 1 to number of lines of it
- put item 1 of line x of it into line x of theUsers
- end repeat
- pop card
- unlock screen
- unlock messages
- return theUsers
- end userList
-
- -- Retrieves the entire line of information for a given name.
- -- Parsing of the data is left to the local stack, keeping
- -- processing time on the shared stack to a minimum.
- function userData theName
- put numToChar(15) after theName
- put lineNumber(theName,fld "Group Status" of cd 1) into whichLine
- return line whichLine of fld "Group Status" of cd 1
- end userData
- </script>
- <background id="2814" file="background_2814.xml" name="Mine" />
- <background id="4190" file="background_4190.xml" name="Other" />
- <background id="4820" file="background_4820.xml" name="" />
- <card id="2850" file="card_2850.xml" marked="false" name="Current Status" owner="2814" />
- <card id="3904" file="card_3904.xml" marked="false" name="Other" owner="4190" />
- <card id="4957" file="card_4957.xml" marked="false" name="About" owner="4820" />
- <card id="5305" file="card_5305.xml" marked="false" name="Help" owner="4820" />
- </stack>
-